﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLACQUY
{
    public partial class BaoCao2 : Form
    {
        private string TienChu;
        private int _MaKH;
        private int _MaPhieuGiaoHang;
        public BaoCao2()
        {
            InitializeComponent();
        }
        public BaoCao2(string tienchu, int makh, int maphieu)
        {
            InitializeComponent();
            TienChu = tienchu;
            _MaKH = makh;
            _MaPhieuGiaoHang = maphieu;
        }

        private void BaoCao2_Load(object sender, EventArgs e)
        {
            CrystalReport1 rpt = new CrystalReport1();
            //PhieuGiaoHangReport rpt = new PhieuGiaoHangReport();
            rpt.SetParameterValue("MaKH", _MaKH);
            rpt.SetParameterValue("MaPhieuGiaoHang", _MaPhieuGiaoHang);
            rpt.SetParameterValue("TienChu", TienChu);
            for (int i = 0; i < rpt.ParameterFields.Count; i++ )
            {
                rpt.ParameterFields[i].HasCurrentValue = true;
            }

            crystalReportViewer1.ParameterFieldInfo = rpt.ParameterFields;

            CrystalDecisions.Shared.TableLogOnInfo curTLI;
            foreach (CrystalDecisions.CrystalReports.Engine.Table curtb in rpt.Database.Tables)
            {
                curTLI = curtb.LogOnInfo;
                curTLI.ConnectionInfo.ServerName = Application.StartupPath + "\\acquydatabase.mdb";
                curTLI.ConnectionInfo.UserID = "Admin";
                curTLI.ConnectionInfo.Password = "";
                curTLI.ConnectionInfo.DatabaseName = "";
                curtb.ApplyLogOnInfo(curTLI);

            }

            crystalReportViewer1.ReportSource = rpt;
        }
    }
}
